import React from 'react';
import {connect} from 'react-redux';
 class AppReactRadux extends React.Component{
     constructor(props){
         super(props);
         console.log(props)
     }
     render(){
         return(
             <div>
                 {this.props.count}
                <button onClick={e=>this.props.addCount()}>添加</button>
                <button onClick={e=>this.props.decCount()}>减少</button>
             </div>
         )
     }
 }

 function mapStateToProps(state){
     return{
         count:state
     }
 }

 function mapDispatchToProps(dispatch){
     return{
        addCount(){
            dispatch({type:'INCREMENT'})
        },
        decCount(){
            dispatch({type:'DECREMENT'})
        }
     }
 }
 const compontentConnect=connect(mapStateToProps,mapDispatchToProps)

 export default compontentConnect(AppReactRadux)